﻿<UserControl x:Class="ToDoList.Reports.TaskGrid"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:SampleData="clr-namespace:ToDoList.SampleData" xmlns:Converters="clr-namespace:ToDoList.Converters"
             mc:Ignorable="d"
    d:DesignHeight="1100" d:DesignWidth="820">
    
    <Grid x:Name="LayoutRoot" Background="White" Width="816" Height="1056"
            d:DataContext="{d:DesignInstance SampleData:DesignTaskGridReportViewModel, IsDesignTimeCreatable=true}">
        <Grid.Resources>
            <Style x:Key="BaseReport" 
                    TargetType="TextBlock">
                <Setter Property="FontFamily" 
                        Value="Times New Roman"/>
                <Setter Property="Foreground" 
                        Value="Black"/>
                <Setter Property="VerticalAlignment" 
                        Value="Center"/>
            </Style>
            <Style TargetType="TextBlock" 
                    BasedOn="{StaticResource BaseReport}"/>
        </Grid.Resources>
        <Grid HorizontalAlignment="Stretch" 
                VerticalAlignment="Stretch" 
                Margin="96">
            <Grid.RowDefinitions>
                <RowDefinition Height="48"/>
                <RowDefinition Height="10"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="10"/>
                <RowDefinition Height="48"/>
            </Grid.RowDefinitions>
            <TextBlock Text="Task List" 
                        FontWeight="Bold" 
                        HorizontalAlignment="Center"/>
            <Rectangle Fill="Black" 
                        Height="1" 
                        HorizontalAlignment="Stretch" 
                        Grid.Row="1"/>
            <Rectangle Fill="Black" 
                        Height="1" 
                        HorizontalAlignment="Stretch" 
                        Grid.Row="4"/>
            <Grid HorizontalAlignment="Stretch" Grid.Row="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150"/>
                    <ColumnDefinition Width="300"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBlock Text="Title" 
                            FontWeight="Bold"/>
                <TextBlock Text="Description" 
                            FontWeight="Bold" 
                            Grid.Column="1"/>
                <TextBlock Text="Status" 
                            FontWeight="Bold" 
                            Grid.Column="2"/>
                <Rectangle Fill="Black" Height="2" 
                            HorizontalAlignment="Stretch" 
                            Grid.Row="1"
                            Grid.ColumnSpan="3"/>                
            </Grid>
            <ItemsControl ItemsSource="{Binding Tasks}" Grid.Row="3">
                <ItemsControl.Resources>
                    <Converters:ToDoListItemStatusConverter 
                        x:Key="StatusConverter"/>
                </ItemsControl.Resources>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">                            
                            <TextBlock Width="150" 
                                        Text="{Binding Title}" 
                                        Style="{StaticResource BaseReport}"/>
                            <TextBlock Width="300" 
                                        Text="{Binding Description}" 
                                        Style="{StaticResource BaseReport}"
                                        TextTrimming="WordEllipsis"/>   
                            <TextBlock Text="{Binding Converter={StaticResource StatusConverter}}"
                                        Style="{StaticResource BaseReport}"/>
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
            <StackPanel Grid.Row="5" Orientation="Horizontal">
                <TextBlock Text="Report For: "/>
                <TextBlock Text="{Binding UserName}"/>                
            </StackPanel>
            <StackPanel Grid.Row="5" 
                        HorizontalAlignment="Right" 
                        Orientation="Vertical"
                        VerticalAlignment="Center">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Printed On: "/>
                    <TextBlock Text="{Binding PrintDate}"/>                    
                </StackPanel>
                <StackPanel Orientation="Horizontal" 
                            HorizontalAlignment="Right">
                    <TextBlock Text="Page "/>
                    <TextBlock Text="{Binding Page}"/>
                    <TextBlock Text=" of "/>
                    <TextBlock Text="{Binding TotalPages}"/>                    
                </StackPanel>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
